package com.alan.springBoot.config;

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.internal.DefaultCommentGenerator;

/**
 * 注释控制类
 * @author alan
 * @version 创建时间：2016年11月7日 上午11:45:06
 */
public class AlanCommentGenerator extends DefaultCommentGenerator {


	/**
	 * Mybatis的Mapper.xml文件里面的注释
	 * @param xmlElement
	 */
	@Override
	public void addComment(XmlElement xmlElement) {
		// TODO Auto-generated method stub
		//super.addComment(xmlElement);
	}

	/**
	 * 为根元素的第一个子节点添加注释
	 * @param rootElement
	 */
	@Override
	public void addRootComment(XmlElement rootElement) {
		// TODO Auto-generated method stub
		super.addRootComment(rootElement);
	}

	/**
	 * 类注释
	 * @param innerClass
	 * @param introspectedTable
	 */
	@Override
	public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
		//super.addClassComment(innerClass, introspectedTable);
	}

	/**
	 * 类注释
	 * @param innerClass
	 * @param introspectedTable
	 * @param markAsDoNotDelete
	 */
	@Override
	public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {
		//super.addClassComment(innerClass, introspectedTable, markAsDoNotDelete);
	}

	/**
	 * 普通方法注释,mapper接口中方法
	 * @param method
	 * @param introspectedTable
	 */
	@Override
	public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
		//super.addGeneralMethodComment(method, introspectedTable);
	}

	/**
	 * setter方法注释
	 * @param method
	 * @param introspectedTable
	 * @param introspectedColumn
	 */
	@Override
	public void addGetterComment(Method method, IntrospectedTable introspectedTable,
			IntrospectedColumn introspectedColumn) {
		//super.addGetterComment(method, introspectedTable, introspectedColumn);
	}

	/**
	 * Getter方法注释
	 * @param method
	 * @param introspectedTable
	 * @param introspectedColumn
	 */
	@Override
	public void addSetterComment(Method method, IntrospectedTable introspectedTable,
			IntrospectedColumn introspectedColumn) {
		//super.addSetterComment(method, introspectedTable, introspectedColumn);
	}

	/**
	 * 字段注释
	 * @param field
	 * @param introspectedTable
	 * @param introspectedColumn
	 */
	@Override
	public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
		field.addJavaDocLine("/**");
		field.addJavaDocLine(" * @Fields "+field.getName()+" "+introspectedColumn.getRemarks());
		field.addJavaDocLine(" */");
		/*StringBuffer sb = new StringBuffer();
		field.addJavaDocLine("/**");
		field.addJavaDocLine(" * <pre>");
		if (introspectedColumn.getRemarks() != null &&
				!"".equals(introspectedColumn.getRemarks())){
			field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
		}
		sb.append(" * 表字段 : ");
		sb.append(introspectedTable.getFullyQualifiedTable());
		sb.append('.');
		sb.append(introspectedColumn.getActualColumnName());
		field.addJavaDocLine(sb.toString());
		field.addJavaDocLine(" * </pre>");
		field.addJavaDocLine(" * ");
		// addJavadocTag(field, false); */
		//field.addJavaDocLine(" */");
	}

	/**
	 * 字段注释
	 * @param field
	 * @param introspectedTable
	 */
	@Override
	public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
		//super.addFieldComment(field, introspectedTable);
	}

}
